package com.visikard.business;

import android.util.Log;

import com.visikard.application.Constant;
import com.visikard.net.VKregisterNetworkException;
import com.visikard.request.DetailRedeemRequest;
import com.visikard.response.BaseResponse;
import com.visikard.response.GetDetailRedeemResponse;

public class TransactionDetailBUS {

	public GetDetailRedeemResponse getDetailsRedeemGiftKard(final long merchantId, final long redeemedTransactionId,
			final long purchaseTransactionId) {

		DetailRedeemRequest ar = new DetailRedeemRequest();
		GetDetailRedeemResponse result = new GetDetailRedeemResponse();
		try {
			String response = ar.getDetailsRedeemGiftKard(merchantId, redeemedTransactionId, purchaseTransactionId);
			result.extractDataFromServer(response);
		}
		catch (VKregisterNetworkException e) {
			Log.e(Constant.LOG_TAG, "getDetailsRedeemGiftKard: " + e.getMessage());
			result.setErrorCode(BaseResponse.NETWORK_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		catch (Exception e) {
			Log.e(Constant.LOG_TAG, "getDetailsRedeemGiftKard: " + e.getMessage());
			result.setErrorCode(BaseResponse.UNKNOWN_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		return result;
	}

	public GetDetailRedeemResponse getDetailsRedeemCouponKard(final long merchantId, final long redeemedTransactionId,
			final long purchaseTransactionId) {

		DetailRedeemRequest ar = new DetailRedeemRequest();
		GetDetailRedeemResponse result = new GetDetailRedeemResponse();
		try {
			String response = ar.getDetailsRedeemCouponKard(merchantId, redeemedTransactionId, purchaseTransactionId);
			result.extractDataFromServer(response);
		}
		catch (VKregisterNetworkException e) {
			Log.e(Constant.LOG_TAG, "getAllCoupons: " + e.getMessage());
			result.setErrorCode(BaseResponse.NETWORK_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		catch (Exception e) {
			Log.e(Constant.LOG_TAG, "getAllCoupons: " + e.getMessage());
			result.setErrorCode(BaseResponse.UNKNOWN_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		return result;
	}

	public GetDetailRedeemResponse getDetailsRedeemPunchKard(final long merchantId, final long redeemedTransactionId,
			final long purchaseTransactionId) {

		DetailRedeemRequest ar = new DetailRedeemRequest();
		GetDetailRedeemResponse result = new GetDetailRedeemResponse();
		try {
			String response = ar.getDetailsRedeemPunchKard(merchantId, redeemedTransactionId, purchaseTransactionId);
			result.extractDataFromServer(response);
		}
		catch (VKregisterNetworkException e) {
			Log.e(Constant.LOG_TAG, "getAllCoupons: " + e.getMessage());
			result.setErrorCode(BaseResponse.NETWORK_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		catch (Exception e) {
			Log.e(Constant.LOG_TAG, "getAllCoupons: " + e.getMessage());
			result.setErrorCode(BaseResponse.UNKNOWN_ERROR);
			result.setErrorMsg(e.getMessage());
		}
		return result;
	}

}
